package com.app.bimo.commonbusiness.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.app.bimo.commonbusiness.R;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshInternal;

public class BimoRefreshLayout extends SmartRefreshLayout {
    private int layoutId;
    public BimoRefreshLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.BimoRefreshLayout);
        layoutId=ta.getResourceId(R.styleable.BimoRefreshLayout_view_layout,R.layout.view_refresh);
        initView();
        // TODO Auto-generated constructor stub
    }

    public BimoRefreshLayout(Context context) {
        this(context, null);
        // TODO Auto-generated constructor stub
    }

    public void initView() {
        LayoutInflater.from(getContext()).inflate(layoutId,this,true);
    }

    public <T extends RefreshInternal> T getHeadView(){
        return (T)mRefreshHeader.getView();
    }

    public <T extends View> T getContentView(){
        return (T)mRefreshContent.getView();
    }

    public void addContent(View view){
        ViewGroup viewGroup=(ViewGroup) view.getParent();
        viewGroup.removeView(view);
        setRefreshContent(view);
    }
}
